<?php

namespace app\helpers;

class Time
{

    public static function getTimeLabel($time)
    {
        //获取今天凌晨的时间戳
        $day = strtotime(date('Y-m-d', time()));
        //获取昨天凌晨的时间戳
        $pday = strtotime(date('Y-m-d', strtotime('-1 day')));
        $str = '';
        if ($time <= $pday) {
            $str = date('Y-m-d', $time);
        } elseif ($time < $day && $time > $pday) {
            $str = "昨天";
        } else if ($time >= $day) {
            $str = date('G:i:s', $time);
        }
        return $str;
    }
}